const jwt = require('jsonwebtoken')
const { secretKey, expiresIn } = require('../constants/const')

module.exports = {
  generateToken: (openId) => {
    const payload = {
      openId,
      iat: Math.floor(Date.now() / 1000), // 签发时间
    }
    const token = jwt.sign(payload, secretKey, {
      expiresIn,
    })
    return token
  },
}
